package com.lzw.mall.common.mapper;

import com.lzw.mall.common.entity.MemberAddress;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lizhenwei
 * @since 2023-04-07
 */
public interface MemberAddressMapper extends BaseMapper<MemberAddress> {

    @Select("select * from member_address where member_id=#{id}")
    List<MemberAddress> selectByMemberId(Integer id);

    @Delete("delete from member_address where member_id=#{id1} and id=#{id}")
    void delMemberAddress(@Param("id") Integer id, @Param("id1") Integer id1);


    @Update("update member_address set default_addr=0 where id=#{id}")
    void updataMemberAddressDefaultAddr(Integer id);

    @Update("update member_address set default_addr=1 where member_id=#{id}")
    void updataMemberAddressDefaultAddrSet1(Integer id);

    @Select("select * from member_address where member_id=#{id}")
    List<MemberAddress> selectMemberAddress(Integer id);

    @Select("select * from member_address where id=#{id}")
    MemberAddress selMemberAddressById(Integer id);


}
